package com.feicheng.controller.main.admin.system;

import com.alibaba.fastjson.JSONObject;
import com.feicheng.common.constant.Constant;
import com.feicheng.common.result.ResultInfo;
import com.feicheng.service.IFLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

@RestController("/main/admin/system/login")
@RequestMapping("/main/admin/system/login")
public class LoginController {

    @Resource(name="main-system-login")
    Map<String, IFLoginService> systemLoginService;
    @PutMapping("/ap")
    public ResultInfo login(String account, String password) {
        JSONObject param = new JSONObject();
        param.put(Constant.ENTITY.USER.ACCOUNT, account);
        param.put(Constant.ENTITY.USER.PASSWORD, password);
        return systemLoginService.get(Constant.LOGIN_TYPE.AP).login(param.toJSONString());
    }

    @GetMapping("/tm")
    public ResultInfo loginTm(String tel, String code) {
        JSONObject param = new JSONObject();
        return systemLoginService.get(Constant.LOGIN_TYPE.TM).login(param.toJSONString());
    }

}
